#ifndef _GEO_TIFF_IMAGE_HXX_
#define _GEO_TIFF_IMAGE_HXX_

#include <opencv/cv.h>

class GeoTiffImage
{
public:
	GeoTiffImage();
	~GeoTiffImage();

	inline void setWidth(unsigned int width) { _imageWidth = width; }
	inline void setHeight(unsigned int height) { _imageHeight = height; }
	inline void setChannels(unsigned int channels) { _channels = channels; }
	inline void setDepth(unsigned int depth) { _depth = depth; }

	inline unsigned int getWidth() { return _imageWidth; }
	inline unsigned int getHeight() { return _imageHeight; }
	inline unsigned int getChannels() { return _channels; }
	inline unsigned int getDepth() { return _depth; }

	inline unsigned char* getImageData() { return _imageData; }

	inline void setGeoScale(const double sx, const double sy, const double sz) { _geoScale[0] = sx; _geoScale[1] = sy; _geoScale[2] = sz; }
	inline void setGeoControlPoint(double* controlPoint) { for (int i = 0; i < 6; i++) _geoControlPoint[i] = controlPoint[i]; }

	inline void getGeoScale(double &sx, double& sy, double& sz) { sx = _geoScale[0]; sy = _geoScale[1]; sz = _geoScale[2]; }
	inline void getGeoGridCoord(double& gx, double& gy, double& gz) { gx = _geoControlPoint[0]; gy = _geoControlPoint[1]; gz = _geoControlPoint[2]; }
	inline void getGeoModelCoord(double& gx, double& gy, double& gz) { gx = _geoControlPoint[3]; gy = _geoControlPoint[4]; gz = _geoControlPoint[5]; }

	IplImage* convert2IplImage();

	void refreshDataSpace();

	inline void setMinValue(float val) { _minValue = val; }
	inline void setMaxValue(float val) { _maxValue = val; }
	inline float getMinValue() { return _minValue; }
	inline float getMaxValue() { return _maxValue; }

	void resizeTo(GeoTiffImage* target, int width, int height);

	void splitImage(const char* imageDirectory);

private:
	unsigned int _imageWidth;
	unsigned int _imageHeight;
	unsigned int _channels;
	unsigned int _depth;
	unsigned char* _imageData;

	double _geoScale[3];
	double _geoControlPoint[6];

	float _minValue;
	float _maxValue;
};
#endif